package io;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class Test3 {
    public static void main(String[] args) throws IOException {
        File dir = new File("BJava_SE_API/src/io");
        if(dir.isDirectory()){
            File[] subs = dir.listFiles(f->f.getName().endsWith(".java"));
            for(int i=0;i<subs.length;i++){
                System.out.println(subs[i].getName());
                FileInputStream fis = new FileInputStream(subs[i]);
                long len = subs[i].length();
                System.out.println("文件大小:"+len);
                byte[] data = new byte[(int)len];
                fis.read(data);
                String line = new String(data, StandardCharsets.UTF_8);
                System.out.println(line);
                fis.close();
            }
        }
    }
}
